chapter four~five

Parentheses Override Precedence and Associativity

1
2
3
4
5
6
7
8
Managing Compound Expressions
1. When in doubt, parenthesize expressions
to force the grouping that the
logic of your program requires.
2. If you change the value of an operand,
don’t use that operand elsewhere
in the same expresion

Assignment is right associative.
Shift Operators (aka IO Operators) Are Left Associative.
sizeof operator returns the size, in bytes, of an expression or a type name.
right associative
sizeof expr :not evaluate the value but return the type returned by the given expression
sizeof a reference type returns the size of an object of the referenced type
sizeof an array is the size of the entire array

A block is not terminated by a semicolon

Exception handling

Throw :raise an exception and terminates the current function.
Try: deal with exception. one or more catch clauses

1
2
3
try { program-statements}
catch (exception-declaration) { handler-statements}
catch (exception-declaration) { handler-statements}

onece one catch executed,execution continues with the statement immediately following the last catch clause of the try block
variable declared inside a try block are inaccessible outside the block as well as to catch clauses.
If a program has no try blocks and an exception occurs, then terminate is called and the program is exited.

Comments:exception and leakage